/* Table C2 */
use "Analysis Data/voteshare_data.dta", clear

rename cand_party party_name

*Merging in vote-buyer specification
merge m:1 state_name pc_num party_name using "Analysis Data/votebuying.dta", keep(matched) nogen

bys state_name ac_num: egen min_voteshare = min(voteshare_2014)
bys state_name ac_num: egen avg_voteshare = mean(voteshare_2014)
bys state_name ac_num: egen max_voteshare = max(voteshare_2014)

merge m:1 state_name ac_num using "Analysis Data/AC_est_sample.dta", keep(matched) nogen

mean min_v avg_v max_v if treat == 0 [aweight=wgt_treat]

replace party_name = "Other" if inlist(party_name,"NDA","UPA")!=1
bys state_name ac_num party_name: drop if _n>1

keep state_name pc_num ac_num party_name voteshare_2014
reshape wide voteshare_2014, i(state_name pc_num ac_num) j(party_name) string

gen vb_UPA = (voteshare_2014UPA!=.)
gen vb_NDA = (voteshare_2014NDA!=.)
gen vb_Other = (voteshare_2014Other!=.)

gen share_ACs =1
collapse (count) share_ACs, by(vb_NDA vb_UPA vb_Other)
replace share_ACs  =share_ACs/592

sort vb_UPA vb_NDA vb_Other

format share_ACs %9.2f
 tostring vb_*, replace
 foreach var of varlist vb_* {
     replace `var' = "Yes" if `var' == "1"
	 replace `var' = "No" if `var' == "0"
 }

list
